package com.czk.sample;

/**
 * 自定义类加载器加载生成的byte数组
 *
 * @Author:ChenZhangKun
 * @Date: 2021/7/19 23:25
 */
public class MyClassLoader extends ClassLoader {
    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        if ("com.czk.sample.HelloWorld".equals(name)) {
            byte[] bytes = HelloWorldDump.dump();
            Class<?> clazzz = defineClass(name, bytes, 0, bytes.length);
            return clazzz;
        }
        return null;
    }
}
